package com.bishe.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bishe.domain.Users;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class UsersDaoTestCase {

    @Autowired
    private  UsersDao usersDao;

    @Test
    void testGetById(){
        System.out.println(usersDao.selectById(1));
    }

    @Test
    void testGetAll(){
            usersDao.selectList(null);

    }

    @Test
    void testSave(){
        Users users = new Users();
        users.setUid("100");
        users.setPassword("100");
        users.setJudge(1);
         usersDao.insert(users);
    }

    @Test
    void testDelete(){
        usersDao.deleteById(4);
    }

    @Test
    void testUpdate(){
        Users users = new Users();
        users.setId(4);
        users.setPassword("200");
        usersDao.updateById(users);
    }

    @Test
    void testGetPage(){
        IPage page = new Page(2,3);
        usersDao.selectPage(page,null);
    }
    @Test
    void testGetBy1(){
        QueryWrapper<Users> qw = new QueryWrapper<>();
        qw.like("uid","5");
        usersDao.selectList(qw);
    }
    @Test
    void testGetBy2(){
        Integer uid = 5;
        LambdaQueryWrapper<Users> lqw = new LambdaQueryWrapper<>();
        lqw.like(uid != null,Users::getId,uid);
        usersDao.selectList(lqw);
    }
}
